home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 76 / DVD Actual 1 Marzo 2003.iso / Trial / TurboCAD 7.1 Pro / Data.Cab / F29898_pltapi.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-10  |  1.9 KB  |  98 lines

  1. #include "stdafx.h"
  2.  
  3. #include "PalDlg.h"
  4.  
  5. #include "resource.h"
  6.  
  7. UINT WINAPI PltGetHelpID()
  8. {
  9.     return IDD_PALDLG;
  10. }
  11.  
  12. BSTR        WINAPI PltGetDescription()
  13. {
  14.     AFX_MANAGE_STATE(AfxGetStaticModuleState());
  15.  
  16.     CString cstrDesc;
  17.     cstrDesc.LoadString(IDS_DESCRIPTION);
  18.  
  19.     return cstrDesc.AllocSysString();
  20. }
  21.  
  22. BSTR        WINAPI PltGetName()
  23. {
  24.     AFX_MANAGE_STATE(AfxGetStaticModuleState());
  25.  
  26.     CString cstrName;
  27.     cstrName.LoadString(IDS_NAME);
  28.  
  29.     return cstrName.AllocSysString();
  30. }
  31.  
  32. IDispatch*    WINAPI PltGetPicture(BOOL bLargeButton, BOOL bMonochrome)
  33. {
  34.     AFX_MANAGE_STATE(AfxGetStaticModuleState());
  35.  
  36.     LPTSTR IDB = 0;
  37.  
  38.     if (bLargeButton)
  39.     {
  40.         IDB = MAKEINTRESOURCE(IDB_PLT32);
  41.     }
  42.     else
  43.     {
  44.         IDB = MAKEINTRESOURCE(IDB_PLT16);
  45.     }
  46.  
  47.  
  48.     IDispatch *pIPictDisp = NULL;
  49.  
  50.     HBITMAP hbmpPal = ::LoadBitmap(AfxGetResourceHandle(), IDB);
  51.  
  52.     PICTDESC pict;
  53.     pict.cbSizeofstruct = sizeof(pict);
  54.     pict.picType = PICTYPE_BITMAP;
  55.     pict.bmp.hbitmap = hbmpPal;
  56.     pict.bmp.hpal = NULL;
  57.  
  58.     VERIFY(SUCCEEDED(OleCreatePictureIndirect(&pict, IID_IDispatch, TRUE, (void**)&pIPictDisp)));
  59. /*
  60. #ifdef _DEBUG
  61.     IPicture* pIPict = NULL;
  62.     OLE_YSIZE_HIMETRIC height = 0;
  63.     OLE_XSIZE_HIMETRIC width = 0;
  64.     pIPictDisp->QueryInterface(IID_IPicture, (void**)&pIPict);
  65.     if (pIPict != NULL)
  66.     {
  67.         pIPict->get_Height(&height);
  68.         pIPict->get_Width(&width);
  69.         pIPict->Release();
  70.     }
  71. #endif
  72. */
  73.     return pIPictDisp;    
  74. }
  75.  
  76. HINSTANCE MyGetResourceHandle();
  77.  
  78. HWND        WINAPI PltCreateWindow(HWND hwndParent, long nID)
  79. {
  80. //    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  81.  
  82.     HINSTANCE hResOld = AfxGetResourceHandle();
  83.     AfxSetResourceHandle(MyGetResourceHandle());
  84.  
  85.     HWND hwndPal = NULL;
  86.  
  87.     CPalDlg *pDlg = new CPalDlg;
  88.     CWnd *pParentWnd = CWnd::FromHandle(hwndParent);
  89.  
  90.     if (pDlg->Create(IDD_PALDLG, pParentWnd))
  91.         hwndPal = pDlg->GetSafeHwnd();
  92.  
  93.  
  94.     AfxSetResourceHandle(hResOld);
  95.  
  96.     return hwndPal;
  97. }
  98.